﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <title>重庆正大软件职业技术学院题库管理系统登录页面</title>
    <script src="../../Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.simplemodal.1.4.1.min.js" type="text/javascript"></script>
    <link href="../../Content/Styles/LoginStyle.css" rel="stylesheet" type="text/css" />
    <link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">

        $(document).ready(function () {
            $.ajaxSetup({ cache: false });
            SetPosition(); //调整页面
            window.onresize = function () { SetPosition(); };  //屏幕大小改变时调整页面
            InitValidateCode();
        })

        function SetPosition() {
            var screenWidth = getTotalWidth(); //获取浏览器可显示内容的宽度
            var screenHeight = getTotalHeight(); //获取浏览器可显示内容的高度
            var marginLeft = (screenWidth - 600) / 2;
            var marginTop = (screenHeight - 249) / 2 - 75;
            $("#loginFram").css("margin-left", marginLeft + "px");
            $("#loginFram").css("margin-top", marginTop + "px");
        };

        function getTotalHeight() {//获取浏览器可用于显示页面的高度
            if ($.browser.msie) {//如果浏览器是IE
                //如果是兼容性模式则用document.documentElement.clientHeight试获取
                return document.compatMode == "CSS1Compat" ? document.documentElement.clientHeight :
                         document.body.clientHeight;
            } else {//其它浏览器
                return self.innerHeight;
            }
        };

        function getTotalWidth() {//获取浏览器可用于显示页面的宽度

            if ($.browser.msie) {//如果浏览器是IE
                //如果是兼容性模式则用document.documentElement.clientWidth
                return document.compatMode == "CSS1Compat" ? document.documentElement.clientWidth :
                         document.body.clientWidth;
            } else {//其它浏览器
                return self.innerWidth;
            }
        };

        //注册验证码
        function InitValidateCode(){
            //首次加载
            $("#checkCode").attr("src","/Common/GetValidateCode?time=" + (new Date()).getTime());
            //单击验证码事件
            $("#checkCode").bind("click", function () {
                this.src = "/Common/GetValidateCode?time=" + (new Date()).getTime();
                $.get("/Common/GetCurrentValidateCode", function (data) {
                    $("#checkCode").val(data);
                });
            });
        };


        function CheckPage() {
            if ($("#txtAccount").val() == "") {
                alert("请填写用户名！");
                return false;
            }
            if ($("#txtPassword").val() == "") {
                alert("请填写密码！");
                return false;
            }
            if ($("#txtCheckCode").val() == "") {
                alert("请填写验证码！");
                return false;
            }
            Login();
        };

        function Login() {
            $.ajax({
                type: "GET",
                url: "/Account/AJAXLogin",
                data: { account: function () { return $("#txtAccount").val() }, password: function () { return $("#txtPassword").val() }, checkCode: function () { return $("#txtCheckCode").val() } },
                beforeSend: function () { $.modal("<img src='@Url.Content("~/Content/Images/loading.gif")' alt=''></img>");},
                success: function (msg) {
                    if (msg == "success") {
                        window.location = "/Home/Index";
                    }
                    else {
                        alert(msg);
                    }
                },
                complete: function () {
                    $("#txtPassword").val("");
                    InitValidateCode();
                    $.modal.close();
                }
            });
        }
    </script>
</head>
<body>
    <div id="loginFram">
        <img src="../../Content/Images/Login/logo.png" width="120" height="50" alt="" />
        <div class="loginFram">
            <div class="top">
                <br />
                <img src="../../Content/Images/Login/Title.png" width="500px;" height="30px;" alt="" />
                <br />
            </div>
            <div class="content">
                <div class="logo">
                    <img src="../../Content/Images/Login/ZD.png" width="130px;" height="130px;" alt="" />
                </div>
                <div class="main">
                    <table>
                        <tr>
                            <td align="right">
                                <span class="loginText">用户名</span>&nbsp;&nbsp;
                            </td>
                            <td>
                                <input id="txtAccount" class="consummateInput" type="text" maxlength="12" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <span class="loginText">密码</span>&nbsp;&nbsp;
                            </td>
                            <td>
                                <input id="txtPassword" class="consummateInput" type="password" maxlength="12" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <span class="loginText">验证码</span>&nbsp;&nbsp;
                            </td>
                            <td>
                                <div class="divTxtCheckCode">
                                    <input id="txtCheckCode" class="txtCheckCode" maxlength="4" type="text" />
                                </div>
                                <div class="divCheckCode" style="float: left; margin-left: 7px;">
                                    <img id="checkCode" class="checkCode" src="/Common/GetCheckCode" alt="" />
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td>
                                <div class="divLogin">
                                    <input class="btn1" type="button" value="登陆" onclick="CheckPage()" /></div>
                                <div class="divRegester">
                                    <input class="btn1" type="button" value="注册" /></div>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="resetPassword">
                <img src="../../Content/Images/Login/help.png" alt="" width="16" height="16" />
                <a href="/Account/ResetPwd">忘记密码</a>&nbsp;&nbsp;&nbsp;
            </div>
        </div>
        <div class="bottom">
            <div class="divPowered">
                QLMS | Powered by .Net Club
            </div>
            <div class="divGroupLogo">
                <img src="../../Content/Images/Login/TeamLogo.png" alt="" width="40" height="16" />
            </div>
        </div>
    </div>
</body>
</html>
